import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path-browserify';

const __dirname = path.dirname(__filename);


// https://vitejs.dev/config/
export default defineConfig({
  plugins: [ vue() ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    }
  },
  server: {
    host: '0.0.0.0',
    port: '8848',
    proxy: {
      '/api': {
        target: 'http://localhost:16636',
        changeOrigin: true,
        rewrite: (path) => path.replace(new RegExp('^' + '/api'), ''),
        bypass: (req, res, options) => {
          const proxyUrl = options.target + options.rewrite(req.url);
          console.log(`真实请求的完整地址proxyUrl: ${proxyUrl}`);
        }
      }
    }
  }
})
